#ifndef _SYNC_QUEUE_H_
#define _SYNC_QUEUE_H_

#include <boost/thread.hpp>
#include <queue>

namespace Field_packing
{
	template <class T>
	class Sync_queue
	{
	public:
		Sync_queue() {}
		void push(const T& t)
		{
			//mt.lock();
			boost::lock_guard<boost::mutex> lkg(mt);
			q.push(t);
			//mt.unlock();
		}
		void pop_front(T& f)
		{
			//mt.lock();
			boost::lock_guard<boost::mutex> lkg(mt);
			f = q.front();
			q.pop();
			//mt.unlock();
			//return f;
		}
		//void pop()
		//{
		//	mt.lock();
		//	q.pop();
		//	mt.unlock();
		//}
		bool empty() const
		{
			bool isempty = true;
			//mt.lock();
			boost::lock_guard<boost::mutex> lkg(mt);
			isempty = q.empty();
			//mt.unlock();
			return isempty;
		}
	private:
		std::queue<T> q;
		mutable boost::mutex mt;
	};
}

#endif